<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<!--    <el-form-item label="显示在页脚的一些信息，不同的信息用'|'分割" prop="params">-->
<!--      <el-input v-model="dataForm.params" placeholder="显示在页脚的一些信息，不同的信息用'|'分割"></el-input>-->
<!--    </el-form-item>-->
<!--    <el-form-item label="免责声明" prop="disclaimer">-->
<!--      <el-input v-model="dataForm.disclaimer" placeholder="免责声明"></el-input>-->
<!--    </el-form-item>-->
<!--    <el-form-item label="用户需知" prop="userAgreement">-->
<!--      <el-input v-model="dataForm.userAgreement" placeholder="用户需知"></el-input>-->
<!--    </el-form-item>-->
<!--      <el-form-item label="名字" prop="key">-->
<!--        <el-input  v-model="dataForm.key" placeholder="" ></el-input>-->
<!--      </el-form-item>-->
      <el-form-item label="内容" prop="value">
        <el-input v-model="dataForm.value" placeholder=""></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          // id: 0,
          // params: '',
          // disclaimer: '',
          // userAgreement: ''
          key:'',
          value:'',
        },
        // dataRule: {
        //   params: [
        //     { required: true, message: '显示在页脚的一些信息，不同的信息用'|'分割不能为空', trigger: 'blur' }
        //   ],
        //   disclaimer: [
        //     { required: true, message: '免责声明不能为空', trigger: 'blur' }
        //   ],
        //   userAgreement: [
        //     { required: true, message: '用户需知不能为空', trigger: 'blur' }
        //   ]
        // }
      }
    },
    methods: {
      init (row) {
        // this.dataForm.id = id || 0
        // console.log(row)
        this.visible = true
       this.dataForm.key=row.key
        this.dataForm.value=row.value

      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/sys/params/upentry`),
              method: 'post',
              data: this.$http.adornData(this.dataForm)
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
